<template>
  <div class="DistributionChannel">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span style="line-height: 36px;">各销售渠道订单状态汇总</span>
      </div>
      <s-table
        :table="table"
        @http="tableWatch">
        <el-form-item slot="multiSelect" label="多选操作" prop="multiSelect" v-if="table.multiSelect">
          <el-row>
            <el-col :span="8">
              <el-button size="small" type="info" @click="tableExport('')">多选导出</el-button>
            </el-col>
          </el-row>
        </el-form-item>
        <el-form-item label="分配时间" prop="fpsj">
          <el-date-picker
            v-model="autoVue_table_fpsj"
            type="daterange"
            placeholder="选择日期范围">
          </el-date-picker>
        </el-form-item>
      </s-table>
    </el-card>
  </div>
</template>

<script>
  import {AutoVue} from '~/plugins/Tools';
  export default AutoVue({
    name: 'journaling_stockCountDaily-FEcarWms',
    head: {
      'title': '各销售渠道订单状态汇总',
      'meta': [
        { 'hid': 'description', 'name': 'description', 'content': '乐速科技平台 各销售渠道订单状态汇总 查看各销售渠道订单状态汇总信息' },
      ],
    },
    data: {
      table: {
        column: [
          { label: '一级',
            prop: 'classA',
            minWidth: '0px',
            search: true,
          },
          { label: '二级',
            prop: 'classB',
            minWidth: '0px',
            search: true,
          },
          { label: '三级',
            prop: 'classC',
            minWidth: '0px',
            search: true,
          },
          { label: '用途',
            prop: 'purpose',
            minWidth: '200px',
            search: false,
          },
          { label: '总销售额',
            prop: 'totalsales',
            minWidth: '0px',
            search: false,
          },
          { label: '订单总量',
            prop: 'ordernumber',
            minWidth: '0px',
            search: false,
          },
          { label: '总支数',
            prop: 'totalnumber',
            minWidth: '0px',
            search: false,
          },
          { label: '已发货金额',
            prop: 'totalamount',
            minWidth: '0px',
            search: false,
          },
          { label: '已发货订单量',
            prop: 'already',
            minWidth: '0px',
            search: false,
          },
          { label: '支数',
            prop: 'supportnumber',
            minWidth: '0px',
            search: false,
          },
          { label: '箱数',
            prop: 'boxes',
            minWidth: '0px',
            search: false,
          },
          { label: '未发货金额',
            prop: 'unconsignment',
            minWidth: '0px',
            search: false,
          },
          { label: '未发货订单量',
            prop: 'unshipped',
            minWidth: '0px',
            search: false,
          },
          { label: '未发货支数',
            prop: 'unconsignmentcount',
            minWidth: '0px',
            search: false,
          },
          { label: '退单金额',
            prop: 'refund',
            minWidth: '0px',
            search: false,
          },
          { label: '退单订单量',
            prop: 'orderquantity',
            minWidth: '0px',
            search: false,
          },
          { label: '退单支数',
            prop: 'regression',
            minWidth: '0px',
            search: false,
          },
          { label: '分配时间',
            prop: 'fpsj',
            minWidth: '0px',
            cRemarks: '',
            type: 'DateRange',
            search: true },
        ],
        url: '/SalesChannelOrderStatusSummaryController/SalesChannel',
        key: 'id',
        tableColumn: 17,
      },
    },
    transition: 'slide-fade',
    methods: {
      tableExport (row) {
        let tableRef = 'table';
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          this[tableRef].multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        this.$confirm('您将导出各销售渠道订单状态汇总报表数据。', '确认导出？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              let option = Object.assign({}, this['autoVue_' + tableRef]);
              await this.p({
                url: '/SalesChannelOrderStatusSummaryController/SalesChannelExcel',
                method: 'post',
                responseType: 'blob',
                data: {
                  ids,
                  ...option,
                },
              });
            } catch (err) {
              console.log(err);
            }
          })
          .catch(_ => {
          });
      },
      // getTime (date) {
      //   this.time = date;
      //   this.table.url = '/SalesChannelOrderStatusSummaryController/SalesChannel';
      //   this.table.option.date = this.time;
      //   this.tableWatch('table');
      // },
    },
    mounted: function () {
      this.tableWatch('table');
    },
  });
</script>

<style scoped lang="scss">
  .block{
    margin: 10px auto;
  }
</style>

<style lang="scss">
</style>
